import { getDicItemByCode, getAllProListByQX } from "@/api/common.js";
export default {
  props: {
    code: {
      type: Object,
      default: "",
    },
  },
  data() {
    return {
      formList: [],
      rules: {},
    };
  },
  mounted() {},
  methods: {
    //查询字典下拉框
    getDicCodeData(code) {
      return new Promise((resolve, reject) => {
        getDicItemByCode({ code })
          .then((res) => {
            let { data } = res;
            resolve(data);
          })
          .catch((_) => {
            reject([]);
          })
          .finally((_) => {});
      });
    },
    //查询项目下拉框
    getProjectData() {
      return new Promise((resolve, reject) => {
        getAllProListByQX()
          .then((res) => {
            let { data } = res;
            resolve(data);
          })
          .catch((_) => {
            reject([]);
          })
          .finally((_) => {});
      });
    },
    //查询归属公司
    getCompanyData() {
      return new Promise((resolve, reject) => {
        this.$get("/mdata/organization/getCompanyList", {})
          .then((res) => {
            let { data } = res;
            resolve(data);
          })
          .catch((_) => {
            reject([]);
          });
      });
    },

    async initFormItems() {
      let { code } = this;
      //项目
      let projectSoucre = await this.getProjectData();
      //公司
      let companySoucre = await this.getCompanyData();
      // 参与方式
      let codeSoucre_1 = await this.getDicCodeData("participationMethod");
      // 标准类型
      let codeSoucre_2 = await this.getDicCodeData("standardType");
      // 收录数据库
      let codeSoucre_3 = await this.getDicCodeData("databaseInclusion");
      // 奖励等级
      let codeSoucre_4 = await this.getDicCodeData("rewardLevel");
      switch (code) {
        // 标准制定
        case "scientifiAchievements.01":
          this.formList = [
            {
              label: "标准名称",
              key: "fileName",
              placeholder: "请输入",
              type: "input",
              required: true,
              message: "请输入标准名称",
            },
            {
              label: "参与方式",
              key: "participationMethod",
              placeholder: "请选择",
              type: "select",
              select_list: codeSoucre_1,
              select_code: "dicItemCode",
              select_name: "dicItemName",
              required: false,
              message: "请选择参与方式",
            },
            {
              label: "标准类型",
              key: "standardType",
              placeholder: "请选择",
              type: "select",
              select_list: codeSoucre_2,
              select_code: "dicItemCode",
              select_name: "dicItemName",
              required: false,
              message: "请选择标准类型",
            },
            {
              label: "批准部门",
              key: "department",
              placeholder: "请输入",
              type: "input",
              required: false,
              message: "请输入批准部门",
            },
            {
              label: "施行日期",
              key: "completedDate",
              placeholder: "请选择",
              type: "date",
              required: true,
              message: "请选择施行日期",
            },
            {
              label: "参编人员",
              key: "completedBy",
              placeholder: "请输入",
              type: "input",
              required: false,
              message: "请输入参编人员",
            },
            {
              label: "关联公司",
              key: "companyCode",
              placeholder: "请选择",
              type: "select",
              select_list: companySoucre,
              select_code: "orgCode",
              select_name: "orgName",
              required: true,
              message: "请选择关联公司",
            },
            {
              label: "关联项目",
              key: "proCode",
              placeholder: "请选择",
              type: "select",
              select_list: projectSoucre,
              select_code: "proCode",
              select_name: "proName",
              required: false,
              message: "请选择关联项目",
            },
            {
              label: "文件",
              key: "files",
              type: "file",
              required: true,
              message: "请选择文件",
            },
          ];
          break;
        //   发明专利
        case "scientifiAchievements.02":
          this.formList = [
            {
              label: "专利名称",
              key: "fileName",
              placeholder: "请输入",
              type: "input",
              required: true,
              message: "请输入专利名称",
            },
            {
              label: "授权日期",
              key: "completedDate",
              placeholder: "请选择",
              type: "date",
              required: true,
              message: "请选择授权日期",
            },
            {
              label: "完成人",
              key: "completedBy",
              placeholder: "请输入",
              type: "input",
              required: false,
              message: "请输入完成人",
            },
            {
              label: "关联公司",
              key: "companyCode",
              placeholder: "请选择",
              type: "select",
              select_list: companySoucre,
              select_code: "orgCode",
              select_name: "orgName",
              required: true,
              message: "请选择关联公司",
            },
            {
              label: "关联项目",
              key: "proCode",
              placeholder: "请选择",
              type: "select",
              select_list: projectSoucre,
              select_code: "proCode",
              select_name: "proName",
              required: false,
              message: "请选择关联项目",
            },
            {
              label: "文件",
              key: "files",
              type: "file",
              required: true,
              message: "请选择文件",
            },
          ];
          break;
        //实用新型专利
        case "scientifiAchievements.03":
          this.formList = [
            {
              label: "专利名称",
              key: "fileName",
              placeholder: "请输入",
              type: "input",
              required: true,
              message: "请输入专利名称",
            },
            {
              label: "授权日期",
              key: "completedDate",
              placeholder: "请选择",
              type: "date",
              required: true,
              message: "请选择授权日期",
            },
            {
              label: "完成人",
              key: "completedBy",
              placeholder: "请输入",
              type: "input",
              required: false,
              message: "请输入完成人",
            },
            {
              label: "关联公司",
              key: "companyCode",
              placeholder: "请选择",
              type: "select",
              select_list: companySoucre,
              select_code: "orgCode",
              select_name: "orgName",
              required: true,
              message: "请选择关联公司",
            },
            {
              label: "关联项目",
              key: "proCode",
              placeholder: "请选择",
              type: "select",
              select_list: projectSoucre,
              select_code: "proCode",
              select_name: "proName",
              required: false,
              message: "请选择关联项目",
            },
            {
              label: "文件",
              key: "files",
              type: "file",
              required: true,
              message: "请选择文件",
            },
          ];
          break;
        //学术论文
        case "scientifiAchievements.04":
          this.formList = [
            {
              label: "论文题目",
              key: "fileName",
              placeholder: "请输入",
              type: "input",
              required: true,
              message: "请输入论文题目",
            },
            {
              label: "期刊名称",
              key: "secondName",
              placeholder: "请输入",
              type: "input",
              required: true,
              message: "请输入期刊名称",
            },
            {
              label: "作者",
              key: "completedBy",
              placeholder: "请输入，多个作者以分号间隔",
              type: "input",
              required: false,
              message: "请输入作者",
            },
            {
              label: "收录数据库",
              key: "databaseInclusion",
              placeholder: "请输入",
              type: "select",
              select_list: codeSoucre_3,
              select_code: "dicItemCode",
              select_name: "dicItemName",
              required: false,
              message: "请选择收录数据库",
            },
            {
              label: "关联公司",
              key: "companyCode",
              placeholder: "请选择",
              type: "select",
              select_list: companySoucre,
              select_code: "orgCode",
              select_name: "orgName",
              required: true,
              message: "请选择关联公司",
            },
            {
              label: "关联项目",
              key: "proCode",
              placeholder: "请选择",
              type: "select",
              select_list: projectSoucre,
              select_code: "proCode",
              select_name: "proName",
              required: false,
              message: "请选择关联项目",
            },
            {
              label: "文件",
              key: "files",
              type: "file",
              required: true,
              message: "请选择文件",
            },
          ];
          break;
        //软件著作权
        case "scientifiAchievements.05":
          this.formList = [
            {
              label: "著作权名称",
              key: "fileName",
              placeholder: "请输入",
              type: "input",
              required: true,
              message: "请输入著作权名称",
            },
            {
              label: "登记日期",
              key: "completedDate",
              placeholder: "请选择",
              type: "date",
              required: true,
              message: "请选择登记日期",
            },
            {
              label: "完成人",
              key: "completedBy",
              placeholder: "请输入",
              type: "input",
              required: false,
              message: "请输入完成人",
            },
            {
              label: "关联公司",
              key: "companyCode",
              placeholder: "请选择",
              type: "select",
              select_list: companySoucre,
              select_code: "orgCode",
              select_name: "orgName",
              required: true,
              message: "请选择关联公司",
            },
            {
              label: "关联项目",
              key: "proCode",
              placeholder: "请选择",
              type: "select",
              select_list: projectSoucre,
              select_code: "proCode",
              select_name: "proName",
              required: false,
              message: "请选择关联项目",
            },
            {
              label: "文件",
              key: "files",
              type: "file",
              required: true,
              message: "请选择文件",
            },
          ];
          break;
        //省部级工艺工法
        case "scientifiAchievements.06":
          this.formList = [
            {
              label: "工法名称",
              key: "fileName",
              placeholder: "请输入",
              type: "input",
              required: true,
              message: "请输入工法名称",
            },
            {
              label: "批准文号",
              key: "fileNumber",
              placeholder: "请输入",
              type: "input",
              required: true,
              message: "请输入批准文号",
            },
            {
              label: "主要完成人",
              key: "completedBy",
              placeholder: "请输入，多个完成人以分号间隔",
              type: "input",
              required: false,
              message: "请输入完成人",
            },
            {
              label: "发证单位",
              key: "department",
              placeholder: "请输入",
              type: "input",
              required: true,
              message: "请输入发证单位",
            },
            {
              label: "关联公司",
              key: "companyCode",
              placeholder: "请选择",
              type: "select",
              select_list: companySoucre,
              select_code: "orgCode",
              select_name: "orgName",
              required: true,
              message: "请选择关联公司",
            },
            {
              label: "关联项目",
              key: "proCode",
              placeholder: "请选择",
              type: "select",
              select_list: projectSoucre,
              select_code: "proCode",
              select_name: "proName",
              required: false,
              message: "请选择关联项目",
            },
            {
              label: "证书",
              key: "files",
              type: "file",
              required: true,
              message: "请选择证书",
            },
            {
              label: "附件",
              key: "secondFiles",
              type: "file",
              required: false,
              message: "请选择附件",
            },
          ];
          break;
        //省部级科技进步奖
        case "scientifiAchievements.07":
          this.formList = [
            {
              label: "项目名称",
              key: "fileName",
              placeholder: "请输入",
              type: "input",
              required: true,
              message: "请输入项目名称",
            },
            {
              label: "奖励名称",
              key: "secondName",
              placeholder: "请输入",
              type: "input",
              required: true,
              message: "请输入奖励名称",
            },
            {
              label: "奖励等级",
              key: "rewardLevel",
              placeholder: "请选择",
              type: "select",
              select_list: codeSoucre_4,
              select_code: "dicItemCode",
              select_name: "dicItemName",
              required: false,
              message: "请选择奖励等级",
            },
            {
              label: "获奖时间",
              key: "completedDate",
              placeholder: "请选择",
              type: "date",
              required: true,
              message: "请选择获奖时间",
            },
            {
              label: "证书编号",
              key: "fileNumber",
              placeholder: "请输入",
              type: "input",
              required: false,
              message: "请输入证书编号",
            },
            {
              label: "发证单位",
              key: "department",
              placeholder: "请输入",
              type: "input",
              required: false,
              message: "请输入发证单位",
            },
            {
              label: "关联公司",
              key: "companyCode",
              placeholder: "请选择",
              type: "select",
              select_list: companySoucre,
              select_code: "orgCode",
              select_name: "orgName",
              required: true,
              message: "请选择关联公司",
            },
            {
              label: "关联项目",
              key: "proCode",
              placeholder: "请选择",
              type: "select",
              select_list: projectSoucre,
              select_code: "proCode",
              select_name: "proName",
              required: false,
              message: "请选择关联项目",
            },
            {
              label: "文件",
              key: "files",
              type: "file",
              required: true,
              message: "请选择文件",
            },
          ];
          break;
        //市级科技进步奖
        case "scientifiAchievements.08":
          this.formList = [
            {
              label: "项目名称",
              key: "fileName",
              placeholder: "请输入",
              type: "input",
              required: true,
              message: "请输入项目名称",
            },
            {
              label: "奖励名称",
              key: "secondName",
              placeholder: "请输入",
              type: "input",
              required: true,
              message: "请输入奖励名称",
            },
            {
              label: "奖励等级",
              key: "rewardLevel",
              placeholder: "请选择",
              type: "select",
              select_list: codeSoucre_4,
              select_code: "dicItemCode",
              select_name: "dicItemName",
              required: false,
              message: "请选择奖励等级",
            },
            {
              label: "获奖时间",
              key: "completedDate",
              placeholder: "请选择",
              type: "date",
              required: true,
              message: "请选择获奖时间",
            },
            {
              label: "证书编号",
              key: "fileNumber",
              placeholder: "请输入",
              type: "input",
              required: false,
              message: "请输入证书编号",
            },
            {
              label: "发证单位",
              key: "department",
              placeholder: "请输入",
              type: "input",
              required: false,
              message: "请输入发证单位",
            },
            {
              label: "关联公司",
              key: "companyCode",
              placeholder: "请选择",
              type: "select",
              select_list: companySoucre,
              select_code: "orgCode",
              select_name: "orgName",
              required: true,
              message: "请选择关联公司",
            },
            {
              label: "关联项目",
              key: "proCode",
              placeholder: "请选择",
              type: "select",
              select_list: projectSoucre,
              select_code: "proCode",
              select_name: "proName",
              required: false,
              message: "请选择关联项目",
            },
            {
              label: "文件",
              key: "files",
              type: "file",
              required: true,
              message: "请选择文件",
            },
          ];
          break;
        //詹天佑奖
        case "scientifiAchievements.09":
          this.formList = [
            {
              label: "项目名称",
              key: "fileName",
              placeholder: "请输入",
              type: "input",
              required: true,
              message: "请输入项目名称",
            },
            {
              label: "奖励名称",
              key: "secondName",
              placeholder: "请输入",
              type: "input",
              required: true,
              message: "请输入奖励名称",
            },
            {
              label: "获奖时间",
              key: "completedDate",
              placeholder: "请选择",
              type: "date",
              required: true,
              message: "请选择获奖时间",
            },
            {
              label: "获奖单位",
              key: "department",
              placeholder: "请输入",
              type: "input",
              required: false,
              message: "请输入获奖单位",
            },
            {
              label: "关联公司",
              key: "companyCode",
              placeholder: "请选择",
              type: "select",
              select_list: companySoucre,
              select_code: "orgCode",
              select_name: "orgName",
              required: true,
              message: "请选择关联公司",
            },
            {
              label: "关联项目",
              key: "proCode",
              placeholder: "请选择",
              type: "select",
              select_list: projectSoucre,
              select_code: "proCode",
              select_name: "proName",
              required: false,
              message: "请选择关联项目",
            },
            {
              label: "文件",
              key: "files",
              type: "file",
              required: true,
              message: "请选择文件",
            },
          ];
          break;
        //专著丛书
        case "scientifiAchievements.10":
          this.formList = [
            {
              label: "专著书名",
              key: "fileName",
              placeholder: "请输入",
              type: "input",
              required: true,
              message: "请输入专著书名",
            },
            {
              label: "出版社",
              key: "secondName",
              placeholder: "请输入",
              type: "input",
              required: true,
              message: "请输入出版社",
            },
            {
              label: "主要编著者",
              key: "completedBy",
              placeholder: "请输入",
              type: "input",
              required: false,
              message: "请输入主要编著者",
            },
            {
              label: "书号ISBN",
              key: "fileNumber",
              placeholder: "请输入",
              type: "input",
              required: true,
              message: "请输入书号ISBN",
            },
            {
              label: "关联公司",
              key: "companyCode",
              placeholder: "请选择",
              type: "select",
              select_list: companySoucre,
              select_code: "orgCode",
              select_name: "orgName",
              required: true,
              message: "请选择关联公司",
            },
            {
              label: "关联项目",
              key: "proCode",
              placeholder: "请选择",
              type: "select",
              select_list: projectSoucre,
              select_code: "proCode",
              select_name: "proName",
              required: false,
              message: "请选择关联项目",
            },
            {
              label: "封面上传",
              key: "files",
              type: "file",
              required: true,
              message: "请选择封面",
            },
            {
              label: "版权页上传",
              key: "secondFiles",
              type: "file",
              required: true,
              message: "请选择版权页",
            },
          ];
          break;
        //集体荣誉
        case "scientifiAchievements.11":
          this.formList = [
            {
              label: "荣誉名称",
              key: "fileName",
              placeholder: "请输入",
              type: "input",
              required: true,
              message: "请输入荣誉名称",
            },
            {
              label: "关联公司",
              key: "companyCode",
              placeholder: "请选择",
              type: "select",
              select_list: companySoucre,
              select_code: "orgCode",
              select_name: "orgName",
              required: true,
              message: "请选择关联公司",
            },
            {
              label: "关联项目",
              key: "proCode",
              placeholder: "请选择",
              type: "select",
              select_list: projectSoucre,
              select_code: "proCode",
              select_name: "proName",
              required: false,
              message: "请选择关联项目",
            },
            {
              label: "文件",
              key: "files",
              type: "file",
              required: true,
              message: "请选择文件",
            },
          ];

          break;
        //优秀经验
        case "scientifiAchievements.12":
          this.formList = [
            {
              label: "经验名称",
              key: "fileName",
              placeholder: "请输入",
              type: "input",
              required: true,
              message: "请输入经验名称",
            },
            {
              label: "完成人",
              key: "completedBy",
              placeholder: "请输入",
              type: "input",
              required: false,
              message: "请输入完成人",
            },
            {
              label: "关联公司",
              key: "companyCode",
              placeholder: "请选择",
              type: "select",
              select_list: companySoucre,
              select_code: "orgCode",
              select_name: "orgName",
              required: true,
              message: "请选择关联公司",
            },
            {
              label: "关联项目",
              key: "proCode",
              placeholder: "请选择",
              type: "select",
              select_list: projectSoucre,
              select_code: "proCode",
              select_name: "proName",
              required: false,
              message: "请选择关联项目",
            },
            {
              label: "文件",
              key: "files",
              type: "file",
              required: true,
              message: "请选择文件",
            },
          ];
          break;
        //四新应用、微创新、其他
        default:
          this.formList = [
            {
              label: "成果名称",
              key: "fileName",
              placeholder: "请输入",
              type: "input",
              required: true,
              message: "请输入成果名称",
            },
            {
              label: "完成人",
              key: "completedBy",
              placeholder: "请输入",
              type: "input",
              required: false,
              message: "请输入完成人",
            },
            {
              label: "关联公司",
              key: "companyCode",
              placeholder: "请选择",
              type: "select",
              select_list: companySoucre,
              select_code: "orgCode",
              select_name: "orgName",
              required: true,
              message: "请选择关联公司",
            },
            {
              label: "关联项目",
              key: "proCode",
              placeholder: "请选择",
              type: "select",
              select_list: projectSoucre,
              select_code: "proCode",
              select_name: "proName",
              required: false,
              message: "请选择关联项目",
            },
            {
              label: "文件",
              key: "files",
              type: "file",
              required: true,
              message: "请选择文件",
            },
          ];
          break;
      }
    },
  },
};
